<include file="Public/head" />

<body>
  <div class="panel admin-panel margin-top">
    <div class="panel-head" id="add"><strong><span class="icon-pencil-square-o"></span> {:L("tianjia")}/{:L("bianji")}</strong></div>
    <div class="body-content">
      <form method="post" class="form-x" action="?" enctype="multipart/form-data">

        <!--<div class="form-group">-->
          <!--<div class="label">-->
            <!--<label>{:L("sahngjifenlei")}：</label>-->
          <!--</div>-->
          <!--<div class="field">-->
            <!--<select class="input w50" name="p_id">-->
              <!--<option value="0">{:L("qingxuanze")}</option>-->
              <!--<foreach name="list" item="v">-->
                <!--<option value="{$v['goods_cate_id']}" <if condition="$info['p_id'] == $v['goods_cate_id']">selected="selected"</if> >{$v['goods_cate_name']}</option>-->
              <!--</foreach>-->
            <!--</select>-->
          <!--</div>-->
        <!--</div>-->

        <div class="form-group">
          <div class="label">
            <label>{:L("fenleibiaoti")}：</label>
          </div>
          <div class="field">
            <input type="text" class="input w50" name="goods_cate_name" value="{$info['goods_cate_name']}" data-validate="required:{:L('qingshuru')}{:L('fenleibiaoti')}"/>
            <div class="tips"></div>
          </div>
        </div>

        <!--<div class="form-group">-->
          <!--<div class="label">-->
            <!--<label>{:L("suolvetu")}：</label>-->
          <!--</div>-->
          <!--<div class="field">-->
            <!--<input type="file" class="button bg-blue" name="cate_thumb" value="+ {:L('liulanshangchuan')}" onchange="preview(this)" style="float: left;">-->
            <!--<div id="preview" name="img" style="float: left;width: 10%;box-sizing: border-box;" class="input" >-->
              <!--<empty name="info['cate_thumb']">-->
                <!--<img src="__PUBLIC__/images/zanwu.jpg" width="100%" />-->
                <!--<else />-->
                <!--<img src="__ROOT__/{$info['thumb']}" width="100%" />-->
              <!--</empty>-->
            <!--</div>-->
            <!--<div class="tipss">{:L("tuijianchicun")}：100*100</div>-->
          <!--</div>-->
        <!--</div>-->
        <!--<div class="tipss"></div>-->

        <div class="form-group">
          <div class="label">
            <label>{:L("paixu")}：</label>
          </div>
          <div class="field">
            <input type="text" class="input w50" name="sort" value="{$info['sort']}"  data-validate="number:{:L('hefapaixu')}" />
            <div class="tipss">（{:L("xinwenpaixu")}）</div>
          </div>
        </div>

        <div class="form-group">
          <div class="label">
            <label></label>
          </div>
          <div class="field">
            <button class="button bg-main icon-check-square-o" type="submit"> {:L("tijiao")}</button>
          </div>
        </div>

      </form>
    </div>
  </div>
</body>
<script src="http://code.jquery.com/jquery-1.8.0.min.js"></script>
<script type="text/javascript">
          $(document).ready(function(){
            $("select[name='goods_type']").change(function(){
              var typeon = $("select[name='goods_type']").val();
              if(typeon==1){$("#mytype").show();}
              else{$("#mytype").hide();$("#mytypeitem").hide();}
            });

            $(".mya1").click(function(){
              var html = '<div class="form-group"> ';
              html += '<div class="label"><label></label></div>';
              html += '<div class="field"> ';
              html += '<input type="text" class="Father_Title input w50" name="spec_name[]" placeholder="{:L("guigemingchen")}" data-validate="required: " />　';
              html += ' <input type="text" class="input w50 check_item" name="item_name[]" placeholder="{:L("guigeshuxing")}" data-validate="required: " />　';
              html += ' <a href="javascript:void(0)" class="mya1 button bg-red" onclick="itemdel(this)">{:L("shanchuguige")}</a>';
              html += '</div></div>';

              $("#mytype").append(html);
            });
          });

  function preview(file)
  {
    var prevDiv = document.getElementById('preview');
    if (file.files && file.files[0])
    {
      var reader = new FileReader();
      reader.onload = function(evt){
        prevDiv.innerHTML = '<img src="' + evt.target.result + '" width="100%" />';
      }
      reader.readAsDataURL(file.files[0]);
    }
    else
    {
      prevDiv.innerHTML = '<div class="img" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src=\'' + file.value + '\'"></div>';
    }
  }
  //单个删除
  function del(id,goods_id,t){
    if(confirm("{:L('shanchuxiaoxi')}")){
      var url = "{:U('goods/delpic')}";
      $.getJSON(url,{id:id,goods_id:goods_id},function (data){
        if(data.result=="true1"){$(t).remove();}
        else if(data.result=="true2"){$(t).next('input[type=hidden]').remove();$(t).remove();}
      })
    }
  }
  function itemdel(t){
    $(t).parents('.form-group').remove();
  }
  //生成表格
  function refreshOptions(){
    $("#mytypeitem").show();
    step.Creat_Table();
  }
</script>
</html>